/*
 * @Descripttion: 
 * @Author: mayuanzheng
 * @Date: 2020-11-27 18:09:15
 * @LastEditors: mayuanzheng
 * @LastEditTime: 2020-11-28 16:01:07
 */

// 首先引入Mock
const Mock = require('mockjs');

// 设置拦截ajax请求的相应时间
Mock.setup({
  timeout: '200-600'
});

// 使用webpack的require.context()遍历所有mock文件
const files = require.context('.', true, /\.js$/);
console.log(files.keys());
files.keys().forEach((key) => {
  if (key === './index.js') return;
  var p = key.substr(1,key.length-4);
  console.log(p)
  Mock.mock(new RegExp('^' +p),'post',files(key)); 
});
console.log(Mock);

export default Mock;